package pack1;

import java.util.Arrays;

public class SelectSort {
    public static void main(String[] args) {
        int[]arr1={3,5,6,88,99,2,1,5};
        int[]arr2={9,8,7,6,5,4,3,2,1};
        selectSort(arr1);
        System.out.println(Arrays.toString(arr1));
    }

    public static void selectSort(int[]arr){
        for (int i = 0; i < arr.length; i++) {
            int minIndex=i+1;
            for (int j = i+1; j < arr.length; j++) {
                if(arr[j]<arr[minIndex]){
                    minIndex=j;
                }
            }
            if(minIndex<arr.length&&arr[i]>arr[minIndex]){
                int temp=arr[i];
                arr[i]=arr[minIndex];
                arr[minIndex]=temp;
            }
        }
    }
}
